package T5_Why_un_synchronized_2_static;
public class Why_synchronized_2 {
	public static void main(String[] args) {    // 为什么锁住了
		Runnable r1 = new MyThread2(); 
		Runnable r2 = new MyThread2(); 
		Thread t1 = new Thread(r1); 
		Thread t2 = new Thread(r2); 
		t1.start(); 
		t2.start(); 
	} 
}  
class MyThread2 implements Runnable{
	public  void run(){ 
		loop();
	} 
	private void loop(){
		synchronized(MyThread.class){
			for(int i=0;i<10;i++) { 
				System.out.print(" " + i); 
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			} 
			System.out.println("  end"); 
		}
	}
}

